package com.itheima.youdianda;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.youdianda.entity.SysConfig;
import com.itheima.youdianda.entity.YddArticle;
import com.itheima.youdianda.service.SysConfigService;
import com.itheima.youdianda.service.YddArticleService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;
import java.util.Map;

@SpringBootTest
@Slf4j
public class test {
    @Autowired
    private SysConfigService sysConfigService;
    @Autowired
    private YddArticleService yddArticleService;

    @Test
    public void test(){
        Page<YddArticle> pageInfo = new Page<>(1,10);
        LambdaQueryWrapper<YddArticle> wrapper = new LambdaQueryWrapper<>();
        // 筛选置顶文章
        wrapper.eq(YddArticle::getIstop,1);
        // 分页查询
        yddArticleService.page(pageInfo,wrapper);
        List<YddArticle> records = pageInfo.getRecords();
        for (YddArticle record : records) {
            System.out.println(record);
        }
    }
}
